<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ include file="/pages/jsp/internal/include.jsp" %>

<div class="inner_cont">
	<h2><fmt:message key="label.fileList"/></h2>
	
	<span class="note">
		
		<fmt:message key="page.fileList.description"/>
		
		<c:forEach items="${model.messages}" var="message">
		   	<div id="message"><fmt:message key="${message}"/></div>
		</c:forEach>
		
		<c:forEach items="${model.errors}" var="error">
		   	<div id="error">
		   		<fmt:message key="${error.key}">
		   			<fmt:param value="${error.param1}"/>
		   		</fmt:message>
		   	</div>
		</c:forEach>
	</span>

<!-- DA SCOMMENTARE PER UPLAOD SU  
	<input type="button" name="upload" id="uploadFileButton" value="upload Files" > 
-->

	<c:if test="${not empty model.files}">
		<form  id="manageFileForm" class="form" method="post">
			
			<table id="tableFileList" class="tableDati col tablesorter">
			
				<thead>
					<tr>
						<th>&nbsp;</th>
				   		<th scope="col"><fmt:message key="th.name"/></th>
				   		<th scope="col"><fmt:message key="th.desc"/></th>
						<th scope="col"><fmt:message key="th.type"/></th>
				   	</tr>
		 		</thead>
		 		
		 		<tfoot>
					<tr>
						<th>&nbsp;</th>
				   		<th scope="col"><fmt:message key="th.name"/></th>
				   		<th scope="col"><fmt:message key="th.desc"/></th>
						<th scope="col"><fmt:message key="th.type"/></th>
				   	</tr>
		 		</tfoot>
		 		
		 		<tbody>
					<c:forEach items="${model.files}" var="file" varStatus="i">
						<tr>
							<td><input type="checkbox" name="fileId" value="<c:out value="${file.id}"/>" ></td>
					   		<td><c:out value="${file.name}"/></td>
							
							<td >
							
								<c:choose>
									
									<c:when test="${empty file.description}">
										<div class="tableTools" style="float:right">
											<!-- <img src="<c:url value="/css/images/minimalistica-icons/png/16x16/pencil.png"/>" onclick="sendFormForAction('<c:url value="/file/modifyFilePage.htm"/>?fileId=<c:out value="${file.id}"/>','manageFileForm','body','fake');"/> -->
										
											<img src="<c:url value="/css/images/minimalistica-icons/png/16x16/pencil.png"/>" onclick="sendFormForAction('<c:url value="/file/modifyFilePage.htm"/>?fileId=<c:out value="${file.id}"/>','manageFileForm','body','fake');"/>
										</div>	
									</c:when>
									
									
									<c:otherwise>
									
										<c:out value="${file.description}"/>
										<div class="tableTools" style="float:right">
											<img src="<c:url value="/css/images/minimalistica-icons/png/16x16/pencil.png"/>" onclick="sendFormForAction('<c:url value="/file/modifyFilePage.htm"/>?fileId=<c:out value="${file.id}"/>','manageFileForm','body','fake');"/>
										</div>			
																
									</c:otherwise>
									
								</c:choose>
							</td>
							<td><c:out value="${file.type}"/></td>
					   	</tr>
					 </c:forEach>
				 </tbody>
			</table>
			
			
			<div  id="pager" style="position:relative;top:0px">
				<form>
					<img src="<c:url value="/js/table/first.png"/>" class="first"/>
					<img src="<c:url value="/js/table/prev.png"/>" class="prev"/>
					<input type="text" class="pagedisplay"/>
					<img src="<c:url value="/js/table/next.png"/>" class="next"/>
					<img src="<c:url value="/js/table/last.png"/>" class="last"/>
					<select class="pagesize">
						<option selected="selected" value="10">10</option>
						<option value="20">20</option>
						<option value="30">30</option>
						<option value="40">40</option>
					</select>
				</form> 
			</div>
			<br/>
			<div class="action_bar">
				<!-- <input type="button" class="puls" value="<fmt:message key="label.modDesc"/>" onclick="sendFormForAction('<c:url value="/file/modifyFilePage.htm"/>','manageFileForm','body','fake');"/> -->
				<input type="button" class="puls" value="<fmt:message key="label.delete"/>" onclick="sendFormForAction('<c:url value="/file/manageFile.htm"/>','manageFileForm','body','deleteFile');"/>
			</div>
		</form>
	</c:if>
</div>

<script>
$(document).ready(function() { 
	$("#tableFileList").tablesorter({widthFixed: true}).tablesorterPager({container: $("#pager")});		
});
</script>